﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

/// <summary>
/// Summary description for MailMessages
/// </summary>
public class MailMessages
{
    public static bool sendMail(string mailTo, string titleMail, string contentMail)
    {
        System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
        msg.To.Add(mailTo.Trim());
        msg.From = new MailAddress(LocalVariables.MAIL_ADDRESS.Trim(), LocalVariables.MAIL_TOPIC.Trim(), System.Text.Encoding.UTF8);
        msg.Subject = titleMail.ToString();
        msg.SubjectEncoding = System.Text.Encoding.UTF8;
        msg.Body = contentMail.Trim();
        msg.BodyEncoding = System.Text.Encoding.UTF8;
        msg.IsBodyHtml = true;
        msg.Priority = MailPriority.High;
        SmtpClient client = new SmtpClient();
        client.Credentials = new System.Net.NetworkCredential(LocalVariables.MAIL_ADDRESS.Trim(), LocalVariables.MAIL_PASSWORD.Trim());
        client.Port = 25;
        client.Host = LocalVariables.MAIL_SERVER.Trim();
        client.EnableSsl = true;
        try
        {
            client.Send(msg);
        }
        catch
        {
            return false;
        }
        return true;
    }
}